﻿// JScript File

function ctlHeader_load(ctlID) {
    ctlHeader_selectTab(ctlID);
}

function ctlHeader_selectTab(ctlID) {
    var TabName = document.getElementById(ctlID + "_txtTabName").value;
    var Tab;

    switch (TabName.toUpperCase()) {
        case "TRANG CHỦ":
            Tab = document.getElementById("tabTrangChu");
            Tab.className = "clicked";
            break;
        case "GIỚI THIỆU":
            Tab = document.getElementById("tabGioiThieu");
            Tab.className = "clicked";
            break;
        case "SẢN PHẨM":
            Tab = document.getElementById("tabSanPham");
            Tab.className = "clicked";
            break;
        case "TIN TỨC":
            Tab = document.getElementById("tabTinTuc");
            Tab.className = "clicked";
            break;
        case "LIÊN HỆ":
            Tab = document.getElementById("tabLienHe");
            Tab.className = "clicked";
            break;
    }
}

function ctlHeader_txt_onfocus(txtID) {

    var txt = document.getElementById(txtID);
    if(txtID.indexOf("txtDiaChi")>=0)
    {
        if(txt.value.toUpperCase()=="ĐỊA CHỈ")
        {
            txt.value="";
        }
    }
    else
    {
        if(txt.value.toUpperCase()=="MÃ TIN RAO")
        {
            txt.value="";
        }
    }
    txt.select();
}

function ctlHeader_txt_onblur(txtID)
{
    var txt = document.getElementById(txtID);
    if(txt.value=="")
    {
        if(txtID.indexOf("txtDiaChi")>=0)
        {
            txt.value="Địa chỉ";
        }
        else
        {
            txt.value="Mã tin rao";
        }
    }
    
}


function ChangeTextDefaultPro(obj, string) {
    if (obj.value == '') {
        obj.value = string; obj.style.color = '#444'
    }
    else
        if (obj.value == string) {
            obj.style.color = '#444'
    }
    else {
        obj.style.color = '#444'
    }
}

function ChangeTextFocusPro(obj, string) {
    if (obj.value == string) {
        obj.value = ''; obj.color = '#444'
    }
}
function ChangeTextDefaultBlack(obj, string) {
    if (obj.value == '') {
        obj.value = string; obj.style.color = '#999'
    }
    else
        if (obj.value == string) {
        obj.style.color = '#999'
    }
    else {
        obj.style.color = '#999'
    }
}

function ChangeTextFocusBlack(obj, string) {
    if (obj.value == string) {
        obj.value = ''; obj.color = '#000'
    }
}
function doClickSearchTitle(buttonName, e) {//the purpose of this function is to allow the enter key to point to the correct button to click.
    var key;

    if (window.event)
        key = window.event.keyCode;     //IE
    else
        key = e.which;     //firefox

    if (key == 13) {
        //Get the button the user wants to have clicked
        var btn = document.getElementById(buttonName);
        if (btn != null) { //If we find the button click it
            btn.click();
            event.keyCode = 0
        }
    }
}
function ChangeTextDefaultPro_ID(objID, string, color) {
    var obj = document.getElementById(objID);
    ChangeTextDefaultPro(obj, string, color);
}
function DisPlayLogo(strURL) {
    window.open(strURL);
}
function winOpener(theURL, winName, scrollbars, resizable, width, height) {
    winFeatures = 'left=' + (screen.availWidth - 10 - width) / 2 + ',top=' + (screen.availHeight - 30 - height) / 2 + ',scrollbars=' + scrollbars + ',resizable=' + resizable + ',width=' + width + ',height=' + height + ',toolbar=0,location=0,status=1,menubar=0'
    window.open(theURL, winName, winFeatures);
}
